package net.sxnic.ugr.user.action;

import net.sxnic.ugr.UgrActionSupport;
import net.sxnic.ugr.context.AppContext;
import net.sxnic.ugr.user.User;
import net.sxnic.ugr.user.UserManager;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 
 * Introduction：修改密码action类
 * @author 孙宇飞
 * create date : 2010-5-16
 * @author 吕盛槐 update date : 2011-9-26
 */
@SuppressWarnings("serial")
public class InitPassword extends UgrActionSupport {

    @Autowired
    private UserManager userManager;

     
   
	private User user;

    public String execute() throws Exception {
    	
    	 try {						
    		  
    		  user = userManager.get(id);
    		 
    	        
    	        	 
	            addLog("修改用户 " + user.getUsername() + " 的密码");
	            user.setPassword(DigestUtils.md5Hex("123456"));
	            userManager.update(user);
	            addActionError("初始化密码成功,登录密码和签字密码都是123456！");
	            
    	        
    	      // log
    			addLog("===用户===" + AppContext.getUserName(request)
    					+ "===修改密码成功！===id===" + user.getId());

    	        
    		 
 			
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
        
    	// 保存成功信息并转向
	    
	    
        return  SUCCESS;
    }

    public void setUserManager(UserManager userManager) {
        this.userManager = userManager;
    }

    
    
    public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
